<template>
	<div :class="curClassName" :style="curStyle">
		<van-notice-bar
			v-show="value"
			wrapable
			color="red"
			:scrollable="false"
			:text="value"
		/>
	</div>
</template>
<script setup lang="ts">
import { LoginMessageProps } from './login-message';

const props = defineProps(LoginMessageProps);

/**
 * 项名称
 *
 * @memberof AppLoginMessage
 */
const itemName = computed(() => {
	return props.index || props.index === 0
		? `${props.name}_${props.index}`
		: props.name;
});

/**
 * 当前容器样式
 *
 * @memberof AppLoginMessage
 */
const curStyle = computed(() => {
	const layoutModel = props.layoutModelDetails[itemName.value];
	if (layoutModel) {
		return layoutModel.getElementStyle();
	}
});

/**
 * 类名
 *
 * @memberof AppLoginMessage
 */
const curClassName = computed(() => {
	const layoutModel = props.layoutModelDetails[itemName.value];
	const classNames = {
		'app-login-message': true
	};
	if (layoutModel) {
		Object.assign(classNames, layoutModel.getClassNames());
	}
	return classNames;
});
</script>
